import Weapon.Axe;
import Weapon.Sword;
import creature.Corpse;
import creature.Goblin;
import creature.Image;
import creature.Person;

import java.util.Scanner;


public class Sense {
    private Room currentRoom;

    public Sense()
    {
        createRooms();
    }


    Person person1= new Person();
    Image image1= new Image();
    Image image2=new Image();
    Image image3=new Image();

    Goblin goblin1=new Goblin();
    Goblin goblin2=new Goblin();
    Goblin goblin3=new Goblin();

    Corpse corpse1=new Corpse();
    Corpse corpse2=new Corpse();
    Corpse corpse3=new Corpse();



    public void initSense(){
        intiMonster();
        intiPerson();

    }
    public void intiPerson(){
        person1.setId("01");
        person1.setDescription("克里斯-摩恩");
        person1.setHP(300);
        person1.setCurrentWeapon(new Sword("s1","石中剑",-50));

    }
    public void intiMonster(){
        image1.setId("Image1");
        image1.setHP(200);
        image1.setDescription("人偶1");
        image1.setCurrentWeapon(new Axe("A1","巨斧",-20));

        image1.setId("Image2");
        image1.setHP(200);
        image1.setDescription("人偶2");
        image1.setCurrentWeapon(new Axe("A1","巨斧",-20));

        image1.setId("Image3");
        image1.setHP(200);
        image1.setDescription("人偶3");
        image1.setCurrentWeapon(new Axe("A1","巨斧",-20));

        goblin1.setId("Goblin1");
        goblin1.setHP(50);
        goblin1.setDescription("哥布林1");
        goblin1.setCurrentWeapon(new Axe("A4","弯斧",-10));

        goblin2.setId("Goblin2");
        goblin2.setHP(50);
        goblin2.setDescription("哥布林2");
        goblin2.setCurrentWeapon(new Axe("A5","弯斧",-10));

        goblin3.setId("Goblin3");
        goblin3.setHP(50);
        goblin3.setDescription("哥布林3");
        goblin3.setCurrentWeapon(new Axe("A6","弯斧",-10));


        corpse1.setId("Corpse1");
        corpse1.setHP(50);
        corpse1.setDescription("活尸1");
        corpse1.setCurrentWeapon(new Axe("K1","破旧的匕首",-5));

        corpse1.setId("Corpse1");
        corpse1.setHP(50);
        corpse1.setDescription("活尸1");
        corpse1.setCurrentWeapon(new Axe("K1","破旧的匕首",-5));

        corpse1.setId("Corpse1");
        corpse1.setHP(50);
        corpse1.setDescription("活尸1");
        corpse1.setCurrentWeapon(new Axe("K1","破旧的匕首",-5));



    }

    private void createRooms()
    {
        Room outside, lobby, pub, study, bedroom;

        //	制造房间
        outside = new Room("城堡外围");
        lobby = new Room("主殿");
        pub = new Room("血腥酒吧");
        study = new Room("秘偶书房");
        bedroom = new Room("卧室");

        //	初始化房间的出口
        outside.setExits(null, lobby, study, pub);
        lobby.setExits(null, null, null, outside);
        pub.setExits(null, outside, null, null);
        study.setExits(outside, bedroom, null, null);
        bedroom.setExits(null, null, null, study);

        currentRoom = outside;  //	从城堡门外开始
    }

    public void printWelcome(){
        System.out.println("================欢迎来到失落的城堡================");
        System.out.println("=======================序章======================");
        System.out.println("在古老的西大陆，有一个魔法世家克里斯家族，\n" +
                "家族的历史上有一个野心滔天的克里斯伯爵为了权利与金钱，一直崇拜着邪神克苏鲁，\n" +
                "他们在古老的地堡中圈养着邪恶的白色生物，每天以怪兽为食，\n" +
                "直到某一天，伯爵的大儿子杀死了崇拜着邪恶的伯爵，并且移民到了美洲大陆。时间随着到了一战，\n" +
                "詹姆斯 克里斯的父亲死在的战场上，他跟随着遗嘱回到了他的祖宅——这座中世纪的古老城堡。\n");

        System.out.println("\n请输入“Play”--开始游戏。。。。。。。");
        System.out.println();




    }

    public void fightMode(){
        System.out.println("欢迎来到失落的城堡，你现在位于城堡--"+currentRoom);
        System.out.println("遭遇哥布林部落-----请选择战斗：1.战斗(输入“fight1”)--本次为强制战斗");
    }

    public void outside(){
        System.out.println("没啥子好看的");
    }

    public void study(){
        System.out.println("找到一瓶药水件\n这是古老的克苏鲁的配方，用龙烟草\n、鱿鱼的牙齿、克苏鲁的神赐之水，合成的\n生命药水可以恢复部分HP。\n" +
                "\n");
        person1.setHP(person1.getHP()+100);
        System.out.println("当前生命值为"+person1.getHP());

    }


    public void play1(){
        Scanner in = new Scanner(System.in);
        System.out.println("遭遇三只哥布林");

        System.out.println("你可以优先攻击其中一个怪物");

        System.out.println("请选择1-哥布林1，2-哥布林2，3-哥布林3");

        while ( true ) {


            Integer id = Integer.parseInt(in.next());

            if (id == 1) {
                System.out.println("怪物血量："+goblin1.getHP());
                person1.useArticle(person1.getCurrentWeapon(), goblin1);
                System.out.println("显示怪物goblin1血量：" + goblin1.getHP());
                if(goblin1.getHP()<=0){
                    System.out.println("goblin1死亡");
                }
            } else if (id == 2) {
                System.out.println("怪物血量："+goblin2.getHP());
                person1.useArticle(person1.getCurrentWeapon(), goblin2);
                System.out.println("显示怪物goblin2血量：" + goblin2.getHP());
                if(goblin1.getHP()<=0){
                    System.out.println("goblin1死亡");
                }
            } else if (id == 3) {
                System.out.println("怪物血量："+goblin3.getHP());
                person1.useArticle(person1.getCurrentWeapon(), goblin3);
                System.out.println("显示怪物goblin3血量：" + goblin3.getHP());
                if(goblin1.getHP()<=0){
                    System.out.println("goblin1死亡");
                }
            }

            System.out.println("输入4--回合结束");
            Integer id1 = Integer.parseInt(in.next());
            if (id1 == 4) {

                System.out.println("人物初始血量：" + person1.getHP());
                goblin1.useArticle(goblin1.getCurrentWeapon(), person1);
                goblin2.useArticle(goblin2.getCurrentWeapon(), person1);
                goblin3.useArticle(goblin3.getCurrentWeapon(), person1);
                System.out.println("显示人物血量：" + person1.getHP());
                System.out.println("请继续战斗--选择哥布林");
            }

            if (goblin1.getHP() == 0 && goblin2.getHP() == 0 && goblin3.getHP() == 0){
                System.out.println("你已经清理完所有怪物,现在你可以去到下一个房间---输入“go east”");
            break;
            }
        }
    }

    public void audienceHall(){
        Sense sense=new Sense();
        System.out.println("来到破败的古堡的大厅，恶心的腐败味充斥着这个古堡，看看有什么可以探索的。");
        System.out.println("可以检查项目为1.破旧的雕像");
        Scanner in = new Scanner(System.in);
        Integer id3 = Integer.parseInt(in.next());

        if (id3 == 1) {
            System.out.println("破旧的雕塑下面似乎有一封信件，但是有三个扭动着躯体的人挡在前面   你选择：1.走开；2.战斗");
            Integer id4 = Integer.parseInt(in.next());
            if(id4==1){
                System.out.println("选择你的出口。。。");
            }else if (id4==2){
                sense.play2();
            }

        }
    }

    public void BOSS(){
        System.out.println("遭遇最终BOSS----欲望母神");
        System.out.println("母神召唤---三个人偶");
        System.out.println(("你内心恐惧至极---最终你选择---1.战斗到最后，为了家族最后的荣光\n2.逃跑"));

        Scanner in = new Scanner(System.in);

        Integer id5 = Integer.parseInt(in.next());

        if(id5==2){
            System.out.println("你成功逃了出来--但是来至于血脉的召唤，已经天天吸引着克里斯家族的每一个成员");
        }else if(id5==1){
            Integer id6 = Integer.parseInt(in.next());
            System.out.println("你可以优先攻击其中一个怪物");
            System.out.println("请选择1-人偶1，2-人偶2，3-人偶3");
            while ( true ){
                if (id6 == 1) {
                    System.out.println("怪物血量："+image1.getHP());
                    person1.useArticle(corpse1.getCurrentWeapon(), image1);
                    System.out.println("显示怪物goblin1血量：" + image1.getHP());
                    if(corpse1.getHP()<=0){
                        System.out.println("image1死亡");
                    }
                } else if (id6 == 2) {
                    System.out.println("怪物血量："+image2.getHP());
                    person1.useArticle(image2.getCurrentWeapon(), image2);
                    System.out.println("显示怪物goblin2血量：" + image2.getHP());
                    if(image2.getHP()<=0){
                        System.out.println("image2死亡");
                    }
                } else if (id6 == 3) {
                    System.out.println("怪物血量："+image3.getHP());
                    person1.useArticle(person1.getCurrentWeapon(), image3);
                    System.out.println("显示怪物corpse3血量：" + image3.getHP());
                    if(image3.getHP()<=0){
                        System.out.println("image3死亡");
                    }
                }

                System.out.println("输入4--回合结束");
                Integer id1 = Integer.parseInt(in.next());
                if (id1 == 4) {

                    System.out.println("人物初始血量：" + person1.getHP());
                    goblin1.useArticle(goblin1.getCurrentWeapon(), person1);
                    goblin2.useArticle(goblin2.getCurrentWeapon(), person1);
                    goblin3.useArticle(goblin3.getCurrentWeapon(), person1);
                    System.out.println("显示人物血量：" + person1.getHP());
                    System.out.println("请继续战斗--选择活尸");
                }

                if (person1.getHP()<=0||goblin1.getHP()<= 0 && goblin2.getHP() <= 0 && goblin3.getHP() <= 0){
                    System.out.println("你已经清理完所有人偶");

                    System.out.println("可是慢慢的，你发现你看不到欲望母神，她慢慢的变得朦胧");
                    person1.setSan(0);
                    System.out.println("你的San值处于危险的数值---"+person1.getSan());
                    System.out.println("你慢慢地走向了恐惧的深渊");
                    break;
                }
            }

        }




    }

    public void play2(){
        Scanner in = new Scanner(System.in);
        System.out.println("遭遇三只活尸");

        System.out.println("你可以优先攻击其中一个怪物");

        System.out.println("请选择1-活尸1，2-活尸2，3-活尸3");

        while ( true ) {


            Integer id = Integer.parseInt(in.next());

            if (id == 1) {
                System.out.println("怪物血量："+corpse1.getHP());
                person1.useArticle(corpse1.getCurrentWeapon(), corpse1);
                System.out.println("显示怪物goblin1血量：" + corpse1.getHP());
                if(corpse1.getHP()<=0){
                    System.out.println("corpse1死亡");
                }
            } else if (id == 2) {
                System.out.println("怪物血量："+corpse2.getHP());
                person1.useArticle(corpse2.getCurrentWeapon(), corpse2);
                System.out.println("显示怪物goblin2血量：" + corpse2.getHP());
                if(corpse2.getHP()<=0){
                    System.out.println("corpse2死亡");
                }
            } else if (id == 3) {
                System.out.println("怪物血量："+corpse3.getHP());
                person1.useArticle(person1.getCurrentWeapon(), corpse3);
                System.out.println("显示怪物corpse3血量：" + corpse3.getHP());
                if(corpse3.getHP()<=0){
                    System.out.println("corpse3死亡");
                }
            }

            System.out.println("输入4--回合结束");
            Integer id1 = Integer.parseInt(in.next());
            if (id1 == 4) {

                System.out.println("人物初始血量：" + person1.getHP());
                goblin1.useArticle(goblin1.getCurrentWeapon(), person1);
                goblin2.useArticle(goblin2.getCurrentWeapon(), person1);
                goblin3.useArticle(goblin3.getCurrentWeapon(), person1);
                System.out.println("显示人物血量：" + person1.getHP());
                System.out.println("请继续战斗--选择活尸");
            }

            if (goblin1.getHP() == 0 && goblin2.getHP() == 0 && goblin3.getHP() == 0){
                System.out.println("你已经清理完所有怪物");
                System.out.println(("捡到信件：\n古老密文：神血在上，汝这臭猪，待\n吾教尔等享受这滋味....尔当如此为\n我献身!.....大母神!大母神!.....阿提\n斯....神厌憎并诅咒你....愿死亡的阴影\n笼罩你....邪恶和哀痛奖励在你身上!\n"));
                break;
            }
        }
    }
}
